package com.fin.zw.intelligentbot.entity;

import com.fin.zw.intelligentbot.enums.Sex;
import com.fin.zw.intelligentbot.enums.TaskStatus;
import com.fin.zw.intelligentbot.enums.Whether;
import lombok.Data;
import org.hibernate.annotations.Table;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

@Entity
@Table(appliesTo = "task_customer",comment = "任务客户日志关系表")
@Data
public class TaskCustomer implements Serializable {
    @Id
    @Column(nullable = false, columnDefinition = "varchar(64) COMMENT '主键'")
    private String id;

    @Version
    private int version;

    @Column(columnDefinition = "varchar(50) comment '客户姓名'")
    private String name;

    @Column(columnDefinition = "varchar(18) comment '身份证号码'")
    private String idCard;

    @Column(columnDefinition = "varchar(15) comment '电话'")
    private String phone;

    @Column(columnDefinition = "varchar(15) comment '是否是黑名单'")
    @Enumerated(EnumType.STRING)
    private Whether blacklist = Whether.NO;

    @Column(columnDefinition = "varchar(20) COMMENT '性别'")
    @Enumerated(EnumType.STRING)
    private Sex sex = Sex.MALE;

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "task_id",columnDefinition = "varchar(64) comment '任务id'")
    private DialTask dialTask;

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "bot_id",columnDefinition = "varchar(64) comment '机器人id'")
    private RobotInfo robotInfo;

    @Column(columnDefinition = "varchar(30) comment '电话状态'")
    @Enumerated(EnumType.STRING)
    private TaskStatus status = TaskStatus.NEW;

    @Column(columnDefinition = "text comment '扩展内容'")
    private String variable;

    @Column(columnDefinition = "datetime comment '创建时间'")
    private Date createTime;

    @JoinColumn(name = "attitude_id",columnDefinition = "varchar(64) comment '客户分类id'")
    @ManyToOne(fetch = FetchType.EAGER)
    private CategoryLabel attitude;

    @Column(columnDefinition = "datetime COMMENT '呼出时间'")
    private Date startTime;

    @Column(columnDefinition = "datetime COMMENT '通话时间(接听时间)'")
    private Date answerTime;

    @Column(columnDefinition = "datetime COMMENT '转接通话时间'")
    private Date bridgeTime;

    @Column(columnDefinition = "int(11) COMMENT '机器人通话时长'")
    private Integer botDuration;

    @Column(columnDefinition = "int(11) COMMENT '坐席通话时长'")
    private Integer seatsDuration;

    @Column(columnDefinition = "int(11) COMMENT '呼叫时长'")
    private Integer duration;

    @Column(columnDefinition = "int(11) COMMENT '通话时长'")
    private Integer billTime;

    @Column(columnDefinition = "datetime COMMENT '挂断时间'")
    private Date hangupTime;

    @Column(columnDefinition = "datetime COMMENT '结束时间'")
    private Date endTime;

    @ManyToOne(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
    @JoinColumn(name = "company_id",columnDefinition = "varchar(64) comment '企业id'")
    private Company company;

    @OneToOne(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
    @JoinColumn(name = "content_file_id",columnDefinition = "varchar(64) comment '对话内容id'")
    private UploadFile dialogContent;

    @OneToOne(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
    @JoinColumn(name = "record_file_id",columnDefinition = "varchar(64) comment '对话录音id'")
    private UploadFile dialogRecord;

    @ManyToOne(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
    @JoinColumn(name = "sce_id", columnDefinition = "varchar(64) COMMENT '场景id'")
    private SceneInfo scene;

}
